import request from '@/utils/request';

// 接口响应格式
export interface ResumeResponse {
  code: number;
  message: string;
  data: any; // 使用any类型，因为data可能为空或任意结构
}

// 上传简历分析
export async function uploadResume(file: File) {
  const formData = new FormData();
  formData.append('file', file);
  
  return request<ResumeResponse>({
    url: '/resume/analyze',
    method: 'POST',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
    onUploadProgress: (progressEvent) => {
      if (progressEvent.total) {
        const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total);
        console.log(`上传进度: ${percentCompleted}%`);
      }
    },
  });
} 